package main

import (
	"fmt"
	"sync"
	"time"
)

var (
	m  = make(map[int]int)
	wg sync.WaitGroup
)

func get(key int) int {
	return m[key]
}

func set(key, val int) {
	m[key] = val
}

func main() {
	for i := 0; i < 15; i++ {
		wg.Add(1)
		go func(n int) {
			defer wg.Done()
			set(n, n+1)
			time.Sleep(time.Millisecond * 100)
			fmt.Println(n, "->", get(n)) //fatal error: concurrent map writes
		}(i)
	}
	wg.Wait()
}
